<!DOCTYPE html>
<html lang="en">
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
<title>注册</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<!-- description -->
<meta name="description" content="Login Form - Responsive Template">
<link rel="shortcut icon" href="images/favicon.ico" th:href="@{/images/favicon.ico}">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="css/bootstrap.min.css" th:href="@{/css/bootstrap.min.css}">
<!-- Material Design Icons CSS -->
<link rel="stylesheet" href="css/materialdesignicons.css" th:href="@{/css/materialdesignicons.css}">
<!-- Bootstrap Checkbox CSS -->
<link rel="stylesheet" href="css/awesome-bootstrap-checkbox.css" th:href="@{/css/awesome-bootstrap-checkbox.css}">
<!-- Rippler CSS -->
<link rel="stylesheet" href="css/rippler.min.css" th:href="@{/css/rippler.min.css}">
<!-- Style CSS -->
<link rel="stylesheet" href="css/style.css" th:href="@{/css/style.css}">
<!-- Responsive  CSS -->
<link rel="stylesheet" href="css/responsive.css" th:href="@{/css/responsive.css}">
    <style>
        .warning{
            color: red;
        }
    </style>
</head>
<body>

<div class="container py-2">
    <div class="row">
        <div class="col-md-12">
			<div class="logo">
				<a href="#">
					<h1>宠物商店</h1>
				</a>
			</div>
            <div class="row">
                <div class="col-md-6 login-form mx-auto">
                    <!-- form card login -->
                    <div class="card">
                        <div class="card-header">
                            <h3 class="mb-0">注册</h3>
                        </div>
                        <div class="card-body">
                            <form id="formLogin" method="POST" class="formLogin" th:action="@{/register}">
                                <div class="form-group">
                                    <input for="username" class="form-control" id="username" name="username" placeholder="用户名" type="text" required="">
									<i class="fa fa-user"></i>
                                    <div id="message"></div>
                                </div>
                                <div id="message" style="float: right"></div>
                                <div class="form-group">
                                    <input for="password" type="password" name="password" class="form-control" placeholder="密码" id="password" required="">
									<i class="fa fa-lock"></i>
                                </div>
								<div class="form-group">
									<input for="Spassword" type="password" name="Spassword" class="form-control" placeholder="确认密码" id="Spassword" required="">
									<i class="fa fa-lock"></i>
								</div>

                                <div class="form-group" style="display: flex">
                                        <p style="margin-top: 10px;margin-right: 15px">头像:</p>
                                        <input type="file" name="picture" class="form-control" placeholder="选择头像" style="float: right; width: 430px;margin-bottom: 10px "  enctype="multipart/form-data">

                                </div>

								<div class="form-group">
									<input class="form-control" type="text" placeholder="验证码" name="check" id="check"/>
									<span style="cursor:pointer;float: right;height: 34px; width: 30%;">
                        			<img id="CreateCheckCode" style="width: 100%;height:100%;" 	th:src="@{/checkCode}" onclick="Reload()" />
                    				</span>
								</div>



								<div class="row mb-3">
									<div class="col-lg-12 text-center"><button type="submit" class="btn btn-success hover-btn btn-wd " id="btnLogin"><span>注册</span></button></div>
								</div>
                                <div class="warning"></div>
                            </form>
							</div>
                        </div>
                    </div>
                    <!-- /form card login -->
                </div>
            </div>
            <!--/row-->
        </div>
        <!--/col-->
    </div>
    <!--/row-->
</div>
<!--/container-->

<!-- jquery latest version -->
<script src="js/jquery.min.js" th:src="@{/js/jquery.min.js}"></script>
<!-- popper.min.js -->
<script src="js/popper.min.js" th:src ="@{/js/popper.min.js}"></script>
<!-- bootstrap js -->
<script src="js/bootstrap.min.js" th:src="@{/js/bootstrap.min.js}"></script>
<!-- Jquery Rippler js -->
<script src="js/jquery.rippler.min.js" th:src="@{/js/jquery.rippler.min.js}"></script>
<!-- script js -->
<script src="js/script.js" th:src="@{/js/script.js}"></script>
<script src="js/jquery-2.1.4.min.js"></script>
<script>
    $(function (){
        console.log("开始执行入口函数")
        $('#username').blur( function (){
            console.log('触发了onblur函数')
            console.log($('#username').val())
            if ($('#username').val() == '')
                $('#message').html("<text style='color:#22c30c'>用户名不能为空!</text>")
            else {
                $.ajax({
                    type: 'GET',
                    url:'/isUsed',
                    data:'username='+$("#username").val(),
                    success: function (msg){
                        if (msg.message == true){
                            $('#message').html("<text style='color: red'>用户名已存在!</text>");
                        }else {
                            $('#message').html("<text style='color:#22c30c'>用户名合法!</text>");
                        }
                    },

                })
            }
        })
    })

</script>

</body>
</html>